package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
@ToString
public class Customer {
    public static final int GENDER_FEMALE = 0; // 女
    public static final int GENDER_MALE = 1; // 男

    public static final int STATUS_POTENTIAL = 0;  // 潜在
    public static final int STATUS_FORMAL = 1;  // 正式
    public static final int STATUS_POOL = 2;  // 资源池
    public static final int STATUS_LOST = 4;  // 流失
    public static final int STATUS_FAILURE = 3;  // 失败

    private Long id;
    private String name;
    private Integer age;
    private Integer gender;
    private String tel;
    private String qq;
    private SystemDictionaryItem job;
    private SystemDictionaryItem source;
    private Employee seller;
    private Employee inputUser;
    private Date inputTime;
    private int status=STATUS_POTENTIAL;
    private Date positive;

    public String getGenderName() {
        if (this.gender == GENDER_FEMALE) {
            return "女";
        } else {
            return "男";
        }
    }
    public String getStatusName(){
        switch (status){
            case STATUS_POTENTIAL:  return "潜在";
            case STATUS_FORMAL:     return "正式";
            case STATUS_POOL:       return "资源池";
            case STATUS_FAILURE:    return "失败";
            case STATUS_LOST:       return "流失";
            default:                return "未知";
        }
    }
    public String getJsonData(){
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("age", age);
        map.put("gender", gender);
        map.put("tel", tel);
        map.put("qq", qq);
        map.put("jobId", job.getId());
        map.put("sourceId", source.getId());
        map.put("sellerId", seller.getId());
        map.put("sellerName", seller.getName());
       /* 旧销售人员*/
        map.put("oldSellerId", seller.getId());
        map.put("oldSellerName", seller.getName());
        return JSON.toJSON(map).toString();
    }

}